package com.security.frame.core.config;

import com.security.frame.core.common.CommonConstants;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.web.authentication.AuthenticationFailureHandler;
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;

/**
 * 配置基类
 *
 * @author wangjie
 * @version V1.0
 * @date 2019/11/6
 */
public class AbstractChannelSecurityConfig extends WebSecurityConfigurerAdapter {

	@Autowired
	protected AuthenticationSuccessHandler myAuthenticationSuccessHandler;

	@Autowired
	protected AuthenticationFailureHandler myAuthenticationFailureHandler;

	protected void applyPasswordAuthenticationConfig(HttpSecurity http) throws Exception {
		http.formLogin()
			.loginPage(CommonConstants.DEFAULT_UNAUTHENTICATION_URL)
			.loginProcessingUrl(CommonConstants.DEFAULT_LOGIN_PROCESSING_URL_FORM)
			.successHandler(myAuthenticationSuccessHandler)
			.failureHandler(myAuthenticationFailureHandler);
	}
	
}
